package com.yunyu.demo

import android.Manifest
import android.annotation.SuppressLint
import android.content.Context
import androidx.fragment.app.FragmentActivity
import com.tbruyelle.rxpermissions.RxPermissions

class PermissionHelper {
    companion object{
        interface PermissionCb {
            fun onSubscribe(permission: Boolean)
        }
        @SuppressLint("CheckResult")
        fun checkPermission(context:Context, block: PermissionCb) {
            val rxPermissions = RxPermissions(context as FragmentActivity)
            rxPermissions.request(
                Manifest.permission.CAMERA,
                Manifest.permission.RECORD_AUDIO,
//                Manifest.permission.WRITE_EXTERNAL_STORAGE,
//                Manifest.permission.READ_EXTERNAL_STORAGE
            ).subscribe {
                block.onSubscribe(it)
            }
        }
    }
}